var LodashXX = {
    Array:{
        /**
         * chunk(array, [size=1])
         *
         * Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.
         * @param array (Array):array The array to process.
         * @param size [size=1] (number): The length of each chunk
         * @returns {Array} Returns the new array of chunks.
         */
        chunk:function(array,size){
            if(size===null||size===undefined){
                size=1
            }
            //非法判断
            if(array===null||array===undefined||!(array instanceof Array)||size<=0){
                return []
            }
            var result = []
            var index = 0
            while (index<array.length){
                var group = Math.floor(index / size)
                if(index%size===0){
                    //每组第一个,新建数组
                    result[group]=[]
                }
                // 依次将下一个对象插入应该分配的组
                result[group].push(array[index]);
                index++
            }
            return result
        },
        /**
         * Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are falsey.
         * @param array (Array): array The array to compact.
         * @returns {Array} Returns the new array of filtered values.
         */
        compact:function(array){
            //非法判断
            if(array===null||array===undefined||!(array instanceof Array)){
                return []
            }
            var result = []
            for(var i=0;i<array.length;i++){
                var value = array[i]
                if(!value||value===false||value===null||value===0||value===""||value===undefined||isNaN(value)){
                    continue;
                }
                result.push(array[i])
            }
            return result
        },
        /**
         * compact(array)
         *
         * Creates a new array concatenating array with any additional arrays and/or values.
         * @param array array (Array): The array to concatenate.
         * @param [values] (...*): The values to concatenate.
         * @returns {Array} Returns the new concatenated array.
         */
        concat:function(array){
            // js中有个变量arguments,可以访问所有传入的值
            //非法判断
            if(array===null||array===undefined||!(array instanceof Array)){
                return []
            }
            var result = [];
            array.forEach(function(item){
               result.push(item);
            });
            for(var i=1;i<arguments.length;i++){
                var value = arguments[i];
                if(value instanceof Array){
                    //遇到数组要解一层包
                    value.forEach(function(item){
                      result.push(item)
                    })
                }else{
                    result.push(arguments[i])
                }
            }
            return result
        },
        /**
         * difference(array, [values])
         *
         * Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons.
         * The order and references of result values are determined by the first array.
         * Note: Unlike _.pullAll, this method returns a new array.
         * example : _.difference([2, 1], [2, 3]); // => [1]
         * @param array array (Array): The array to inspect.
         * @param value (...Array): The values to exclude.
         * @returns {Array} Returns the new array of filtered values.
         *
         */
        difference:function(array){
            //非法判断
            if(array===null||array===undefined||!(array instanceof Array)){
                return []
            }
            var result = [];
            for(var i=0;i<array.length;i++){
                var exist = false;
                var value = array[i];
                tag:
                    for(var j=1;j<arguments.length;j++) {
                        var argument = arguments[j];
                        if (argument instanceof Array) {
                            for (var k = 0; k < argument.length; k++) {
                                var comparison = argument[k];
                                if (value === comparison) {
                                    exist = true;
                                    break tag //跳出tag循环
                                }
                            }
                        }
                    }
                if(!exist){
                    result.push(value)
                }
            }
            return result
        },
        /**
         * differenceBy(array, [values], [iteratee=_.identity])
         *
         * This method is like _.difference except that it accepts iteratee which is invoked for each element of array
         * and values to generate the criterion by which they're compared.
         * The order and references of result values are determined by the first array.
         * The iteratee is invoked with one argument:(value).
         * Note: Unlike _.pullAllBy, this method returns a new array.
         * Example:
         * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // => [1.2]
         * // The `_.property` iteratee shorthand.
         * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); // => [{ 'x': 2 }]
         * @param array (Array): The array to inspect.
         * @param values (...Array): The values to exclude.
         * @param iteratee (Function): The iteratee invoked per element.
         * @returns {Array} Returns the new array of filtered values.
         * 
         */
        differenceBy:function(array){
            //非法判断
            if(array===null||array===undefined||!(array instanceof Array)){
                return []
            }
            // 获取参数
            var result = [];
            var values = [];
            var iteratee = null;
            if(arguments.length>=2){
                for(var i=1;i<arguments.length-1;i++){
                    values.push(arguments[i])
                }
            }
            if(arguments.length>=3){
                iteratee = arguments[arguments.length-1];
            }
            if(typeof(iteratee)==='string'){
                var property = iteratee;
                iteratee = function (item) {
                    return item[property]
                }
            }else if(typeof(iteratee)==='function'){
            }else if(iteratee instanceof Array){
                values.push(iteratee)
                iteratee = LodashXX.Util.identity
            }
            // 核心
            for(var i=0;i<array.length;i++){
                var exist = false;
                var item = array[i];
                tag:
                    for(var j=0;j<values.length;j++) {
                        var value = values[j];
                        if (value instanceof Array) {
                            for (var k = 0; k < value.length; k++) {
                                var comparison = value[k];
                                if (iteratee(item) === iteratee(comparison)) {
                                    exist = true;
                                    break tag //跳出tag循环
                                }
                            }
                        }
                    }
                if(!exist){
                    result.push(item)
                }
            }
            return result
        }

    },
    Util:{
        /**
         * This method returns the first argument it receives.
         * @param value (*): Any value.
         * @returns value {*}: Returns value.
         */
        identity:function(value) {
            return value
        }
    }


};